<template>

</template>

<script setup lang="ts">
import request from "@/utils/request.ts";
import {onMounted} from "vue";
import {router} from "@/router/router.ts";
const total=router.currentRoute.value.query.total
const subject=router.currentRoute.value.query.subject
const gameIds=router.currentRoute.value.query.gameIds
// 访问后端进行支付宝页面跳转
 onMounted(()=>{
   request.get("/doPay", {params: {gameIds,total,subject}}).then(res=> {
     if (res.code === 0) {
       console.log(res)
       // 添加之前先删除一下，如果单页面，页面不刷新，添加进去的内容会一直保留在页面中，二次调用form表单会出错
       const divForm = document.getElementsByTagName('div');
       if (divForm.length) {
         document.body.removeChild(divForm[0]);
       }
       const div = document.createElement('div');
       div.innerHTML = res.data; // data就是接口返回的form 表单字符串
       document.body.appendChild(div);
       //document.forms[0].setAttribute('target', '_blank');// 新开窗口跳转
       document.forms[0].submit();
     }
   })
 })

</script>

<style scoped>

</style>